/*
 * sys.h
 *
 *  Created on: 2023.02.21
 *      Author: Lw
 */
#ifndef SRC_SYS_H_
#define SRC_SYS_H_
/*PS端主频频率1.3GHZ，1300000000HZ,while循环周期大概为5Mhz*/
#ifndef ON
#define ON  1
#endif

#ifndef OFF
#define OFF  0
#endif

#ifndef SET
#define SET  1
#endif

#ifndef CLOSE
#define CLOSE  0
#endif

#ifndef NULL
#define NULL (void *)(0)
#endif

#ifndef DRV_OK
#define DRV_OK  0
#endif

#ifndef DRV_ERR
#define DRV_ERR 1
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

/*
 * 两字节表示，前1个字节表示嵌入式版本，后1个字节表示fpga版本。
 * 其中每个字节的前2位表示大版本信息，后6位表示小版本信息。
 * eg:0x4143=0b01 000001 01 000011  表示版本为EmV1.01 FpgaV1.03
 * */
#define YW2_PREP_VERSION  0x4445

//#define YW2_PREPA			//选择预处理单机A
#define YW2_PREPB			//选择预处理单机B

#define CORE_START_QSPI     0x01
#define CORE_START_EMMC     0x00

#define YW2_PREPA_ORDER_ACK_CAN_ID            0x130			//预处理单机A传输指令应答ID

#define YW2_PREPB_ORDER_ACK_CAN_ID		      0x134			//预处理单机B传输指令应答ID

#define YW2_PREPA_DATA_ACK_CAN_ID             0x1B0			//预处理单机A数据注入应答ID

#define YW2_PREPB_DATA_ACK_CAN_ID		      0x1B4			//预处理单机B数据注入应答ID

#define YW2_PREPA_TELE_DATA_CAN_FIRST_ID	  0x231			//预处理单机A遥测数据返回首帧ID
#define YW2_PREPA_TELE_DATA_CAN_MID_ID		  0x232			//预处理单机A遥测数据返回中间帧ID
#define YW2_PREPA_TELE_DATA_CAN_LAST_ID		  0x233			//预处理单机A遥测数据返回尾帧ID
#define YW2_PREPA_TELE_DATA_CAN_ADDR_ID       0b01100       //预处理单机A

#define YW2_PREPB_TELE_DATA_CAN_FIRST_ID	  0x235		    //预处理单机B遥测数据返回首帧ID
#define YW2_PREPB_TELE_DATA_CAN_MID_ID		  0x236			//预处理单机B遥测数据返回中间帧ID
#define YW2_PREPB_TELE_DATA_CAN_LAST_ID		  0x237			//预处理单机B遥测数据返回尾帧ID
#define YW2_PREPB_TELE_DATA_CAN_ADDR_ID       0b01101       //预处理单机B节点ID

#define YW2_PREP_TELE_DATA_CAN_BC_ADDR_ID     0b00000       //预处理单机广播节点ID


#ifdef YW2_PREPB
#define YW2_PREP_TELE_DATA_CAN_FIRST_ID	      YW2_PREPB_TELE_DATA_CAN_FIRST_ID
#define YW2_PREP_TELE_DATA_CAN_MID_ID		  YW2_PREPB_TELE_DATA_CAN_MID_ID
#define YW2_PREP_TELE_DATA_CAN_LAST_ID		  YW2_PREPB_TELE_DATA_CAN_LAST_ID
#define YW2_PREP_ORDER_ACK_CAN_ID			  YW2_PREPB_ORDER_ACK_CAN_ID
#define YW2_PREP_DATA_ACK_CAN_ID		  	  YW2_PREPB_DATA_ACK_CAN_ID
#define YW2_PREP_TELE_DATA_CAN_ADDR_ID        YW2_PREPB_TELE_DATA_CAN_ADDR_ID
#endif

#ifdef YW2_PREPA
#define YW2_PREP_TELE_DATA_CAN_FIRST_ID	      YW2_PREPA_TELE_DATA_CAN_FIRST_ID
#define YW2_PREP_TELE_DATA_CAN_MID_ID		  YW2_PREPA_TELE_DATA_CAN_MID_ID
#define YW2_PREP_TELE_DATA_CAN_LAST_ID		  YW2_PREPA_TELE_DATA_CAN_LAST_ID
#define YW2_PREP_ORDER_ACK_CAN_ID			  YW2_PREPA_ORDER_ACK_CAN_ID
#define YW2_PREP_DATA_ACK_CAN_ID		  	  YW2_PREPA_DATA_ACK_CAN_ID
#define YW2_PREP_TELE_DATA_CAN_ADDR_ID		  YW2_PREPA_TELE_DATA_CAN_ADDR_ID
#endif
#define  USE_DEBUG
#define U_SECOND_COUNT                      100//不准确需要确定

#define RAD_TO_DEG(x)		            ((x)*57.2957796f)
#define DEG_TO_RAD(x)		            ((x)*0.01745329f)



#define RAD2DEG                     (57.2957795130823f)
#define DEG2RAD                     (0.01745329251994f)
#define UT2GUSS                     (0.01f)

#define Half_M_PI                   (1.5707963f)
#define MATH_PI	                    (3.141592653589793238462643383280)
#define CONSTANTS_ONE_G             (9.7949f)


#endif /* INC_SYS_H_ */
